package com.czk.servletSpi.impl;

import com.czk.servletSpi.myConfig.WebParameter;

import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;

/**
 * 实现类
 * 将servlet从这二加入
 *
 * @Author:ChenZhangKun
 * @Date: 2021/4/27 22:58
 */
public class MyWebParameter implements WebParameter {
    @Override
    public void onStartUp(ServletContext servletContext) {
        // 加入上下文
        ServletRegistration.Dynamic myServlet = servletContext.addServlet("myServlet", "com.czk.servletSpi.servlet.MyServlet");
        System.out.println("myServlet被加入了");
        //
        myServlet.setLoadOnStartup(1);
        myServlet.addMapping("/test");
    }
}
